/*
dictionary.h
(c) 2010 Yury Hamenkov
This file is part of qWordCards.

qWordCards is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

qWordCards is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with qWordCards. If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef DICT_H
#define DICT_H

#include <QObject>
#include <QFile>
#include <QMap>
#include <QPair>
#include <QCryptographicHash>
#include <QAction>
#include "word.h"
#include "dictziploader.h"


namespace qWordCards {
	
	enum WordType {
		Ordinal = 0,
		Favourite = 1,
		Known = 2,
		Suspended = 3
	};
	
	class WordIndex;
	
	class Dictionary : public QObject {
	Q_OBJECT

	private:
		QString				_fileName;		// Stores filename with path, without suffix (for example /home/user/qWordCards/dicts/en-fr/dict_en-fr)
		unsigned long int	_wordsCount;
		QString				_name;			// Stores name from .ifo file
		QString				_description;
		QByteArray			_hash;
		bool				_loaded;
		bool				_used;
		bool				_error;
		QAction*			_ACTMenuAction;
		QString				_errorText;
		DICTZIPLoader		_loader;
		
		//QList<WordIndex> _indexes;
		
		QMap<QString, WordIndex> _words;
		QMap<QString, WordIndex> _knownWords;
		QMap<QString, WordIndex> _favouriteWords;
		QMap<QString, WordIndex> _suspendedWords;

	public:
		
		
		
		explicit Dictionary(QString filename, QObject *parent = 0);

		// Properties
		bool IsLoaded() const;
		QString GetFileName() const;
		
		bool IsUsed() const;
		void SetUsed(bool u);
		
		QByteArray GetHash() const;
		
		QString GetName() const;
		
		unsigned long int GetWordsCount() const;
		
		QString GetDescription() const;
		
		const QAction* const Action() const;
		
		// Methods
		void Load();
		
		//----------
		void SetFavourite(QString s, bool t);
		void SetKnown(QString s, bool t);
		void SetSuspended(QString s, bool t);
		
		int FavouriteWordsCount() const;
		int KnownWordsCount() const;
		int OrdinalWordsCount() const;
		
		Word GetWord(WordType type);

		QList<QString> GetWordsList() const;
		

		
		
	
		
	signals:
		void sg_Reloaded();

	public slots:

	};
}
#endif // DICT_H
